package org.manusoft.refill.service;

import java.util.List;
import java.util.Map;

import org.manusoft.refill.dao.AllotmentDAO;
import org.manusoft.refill.domain.TRefillingDetailsRf;
import org.primefaces.model.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("allotmentService")
public class AllotmentServiceImpl implements AllotmentService{
	@Autowired
	private AllotmentDAO createAllotmentDAO;
	
	
	@Transactional
	public void createNew(TRefillingDetailsRf refillingDetailsRf) {
		createAllotmentDAO.makePersistent(refillingDetailsRf);
	}

	@Transactional(readOnly=true)
	public List<TRefillingDetailsRf> findAll() {
		return createAllotmentDAO.findAll();
	}
    

	
	@Transactional
	public void update(TRefillingDetailsRf refillingDetailsRf) {
		createAllotmentDAO.makePersistent(refillingDetailsRf);
	}
	
	@Transactional
	public void remove(TRefillingDetailsRf refillingDetailsRf) {
		createAllotmentDAO.remove(refillingDetailsRf);
	}

	@Transactional(readOnly=true)
	public TRefillingDetailsRf findById(Integer id,boolean isLock) {
		return createAllotmentDAO.findById(id,isLock);
	}
	
    @Transactional(readOnly=true)
	public Long getRowCount(Map<String, String> filters) {
		return createAllotmentDAO.getRowCount(filters);
	}

    
    
    @Transactional(readOnly=true)
    public List<TRefillingDetailsRf> loadLazy(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
        return createAllotmentDAO.loadLazy(first, pageSize, sortField, sortOrder == SortOrder.ASCENDING ? "asc" : sortOrder == SortOrder.DESCENDING ? "desc" : null, filters);
    }

	@Override
	public TRefillingDetailsRf createAllotment(
			TRefillingDetailsRf refillingDetailsRf) {
		createAllotmentDAO.makePersistent(refillingDetailsRf);
		return null;
	}

	@Override
	public void delete(TRefillingDetailsRf refillingDetailsRf) {
		// 
		createAllotmentDAO.remove(refillingDetailsRf);
	}
}